package enums;

/**
 * 国家/地区 枚举 (ISO 3166-1 alpha-2)
 */
public enum Country {

    // 亚洲
    CN("CN", "China", "中国", Continent.AS),
    JP("JP", "Japan", "日本", Continent.AS),
    KR("KR", "Korea, Republic of", "韩国", Continent.AS),
    HK("HK", "Hong Kong", "香港", Continent.AS),
    TW("TW", "Taiwan, Province of China", "台湾", Continent.AS),
    MO("MO", "Macao", "澳门", Continent.AS),
    SG("SG", "Singapore", "新加坡", Continent.AS),
    IN("IN", "India", "印度", Continent.AS),
    TH("TH", "Thailand", "泰国", Continent.AS),
    VN("VN", "Viet Nam", "越南", Continent.AS),
    MY("MY", "Malaysia", "马来西亚", Continent.AS),

    // 欧洲
    GB("GB", "United Kingdom", "英国", Continent.EU),
    FR("FR", "France", "法国", Continent.EU),
    DE("DE", "Germany", "德国", Continent.EU),
    IT("IT", "Italy", "意大利", Continent.EU),
    ES("ES", "Spain", "西班牙", Continent.EU),
    RU("RU", "Russian Federation", "俄罗斯", Continent.EU),
    NL("NL", "Netherlands", "荷兰", Continent.EU),
    CH("CH", "Switzerland", "瑞士", Continent.EU),
    SE("SE", "Sweden", "瑞典", Continent.EU),
    PL("PL", "Poland", "波兰", Continent.EU),

    // 北美洲
    US("US", "United States", "美国", Continent.NA),
    CA("CA", "Canada", "加拿大", Continent.NA),
    MX("MX", "Mexico", "墨西哥", Continent.NA),

    // 南美洲
    BR("BR", "Brazil", "巴西", Continent.SA),
    AR("AR", "Argentina", "阿根廷", Continent.SA),

    // 大洋洲
    AU("AU", "Australia", "澳大利亚", Continent.OC),
    NZ("NZ", "New Zealand", "新西兰", Continent.OC),

    // 非洲
    ZA("ZA", "South Africa", "南非", Continent.AF),
    EG("EG", "Egypt", "埃及", Continent.AF),


    // 补充所有国家和地区 (按字母顺序)
    // A
    AF("AF", "Afghanistan", "阿富汗", Continent.AS),
    AX("AX", "Åland Islands", "奥兰", Continent.EU),
    AL("AL", "Albania", "阿尔巴尼亚", Continent.EU),
    DZ("DZ", "Algeria", "阿尔及利亚", Continent.AF),
    AS("AS", "American Samoa", "美属萨摩亚", Continent.OC),
    AD("AD", "Andorra", "安道尔", Continent.EU),
    AO("AO", "Angola", "安哥拉", Continent.AF),
    AI("AI", "Anguilla", "安圭拉", Continent.NA),
    AQ("AQ", "Antarctica", "南极洲", Continent.AN),
    AG("AG", "Antigua and Barbuda", "安提瓜和巴布达", Continent.NA),
    AM("AM", "Armenia", "亚美尼亚", Continent.AS),
    AW("AW", "Aruba", "阿鲁巴", Continent.NA),
    AT("AT", "Austria", "奥地利", Continent.EU),
    AZ("AZ", "Azerbaijan", "阿塞拜疆", Continent.AS),

    // B
    BS("BS", "Bahamas", "巴哈马", Continent.NA),
    BH("BH", "Bahrain", "巴林", Continent.AS),
    BD("BD", "Bangladesh", "孟加拉国", Continent.AS),
    BB("BB", "Barbados", "巴巴多斯", Continent.NA),
    BY("BY", "Belarus", "白俄罗斯", Continent.EU),
    BE("BE", "Belgium", "比利时", Continent.EU),
    BZ("BZ", "Belize", "伯利兹", Continent.NA),
    BJ("BJ", "Benin", "贝宁", Continent.AF),
    BM("BM", "Bermuda", "百慕大", Continent.NA),
    BT("BT", "Bhutan", "不丹", Continent.AS),
    BO("BO", "Bolivia (Plurinational State of)", "玻利维亚", Continent.SA),
    BQ("BQ", "Bonaire, Sint Eustatius and Saba", "荷兰加勒比区", Continent.NA),
    BA("BA", "Bosnia and Herzegovina", "波斯尼亚和黑塞哥维那", Continent.EU),
    BW("BW", "Botswana", "博茨瓦纳", Continent.AF),
    BV("BV", "Bouvet Island", "布韦岛", Continent.AN),
    IO("IO", "British Indian Ocean Territory", "英属印度洋领地", Continent.AS),
    BN("BN", "Brunei Darussalam", "文莱", Continent.AS),
    BG("BG", "Bulgaria", "保加利亚", Continent.EU),
    BF("BF", "Burkina Faso", "布基纳法索", Continent.AF),
    BI("BI", "Burundi", "布隆迪", Continent.AF),

    // C
    CV("CV", "Cabo Verde", "佛得角", Continent.AF),
    KH("KH", "Cambodia", "柬埔寨", Continent.AS),
    CM("CM", "Cameroon", "喀麦隆", Continent.AF),
    KY("KY", "Cayman Islands", "开曼群岛", Continent.NA),
    CF("CF", "Central African Republic", "中非共和国", Continent.AF),
    TD("TD", "Chad", "乍得", Continent.AF),
    CL("CL", "Chile", "智利", Continent.SA),
    CX("CX", "Christmas Island", "圣诞岛", Continent.AS),
    CC("CC", "Cocos (Keeling) Islands", "科科斯（基林）群岛", Continent.AS),
    CO("CO", "Colombia", "哥伦比亚", Continent.SA),
    KM("KM", "Comoros", "科摩罗", Continent.AF),
    CG("CG", "Congo", "刚果共和国", Continent.AF),
    CD("CD", "Congo (Democratic Republic of the)", "刚果民主共和国", Continent.AF),
    CK("CK", "Cook Islands", "库克群岛", Continent.OC),
    CR("CR", "Costa Rica", "哥斯达黎加", Continent.NA),
    CI("CI", "Côte d'Ivoire", "科特迪瓦", Continent.AF),
    HR("HR", "Croatia", "克罗地亚", Continent.EU),
    CU("CU", "Cuba", "古巴", Continent.NA),
    CW("CW", "Curaçao", "库拉索", Continent.NA),
    CY("CY", "Cyprus", "塞浦路斯", Continent.EU),
    CZ("CZ", "Czechia", "捷克", Continent.EU),

    // D
    DK("DK", "Denmark", "丹麦", Continent.EU),
    DJ("DJ", "Djibouti", "吉布提", Continent.AF),
    DM("DM", "Dominica", "多米尼克", Continent.NA),
    DO("DO", "Dominican Republic", "多米尼加共和国", Continent.NA),

    // E
    EC("EC", "Ecuador", "厄瓜多尔", Continent.SA),
    SV("SV", "El Salvador", "萨尔瓦多", Continent.NA),
    GQ("GQ", "Equatorial Guinea", "赤道几内亚", Continent.AF),
    ER("ER", "Eritrea", "厄立特里亚", Continent.AF),
    EE("EE", "Estonia", "爱沙尼亚", Continent.EU),
    SZ("SZ", "Eswatini", "斯威士兰", Continent.AF),
    ET("ET", "Ethiopia", "埃塞俄比亚", Continent.AF),

    // F
    FK("FK", "Falkland Islands (Malvinas)", "福克兰群岛", Continent.SA),
    FO("FO", "Faroe Islands", "法罗群岛", Continent.EU),
    FJ("FJ", "Fiji", "斐济", Continent.OC),
    FI("FI", "Finland", "芬兰", Continent.EU),
    GF("GF", "French Guiana", "法属圭亚那", Continent.SA),
    PF("PF", "French Polynesia", "法属波利尼西亚", Continent.OC),
    TF("TF", "French Southern Territories", "法属南部领地", Continent.AN),

    // G
    GA("GA", "Gabon", "加蓬", Continent.AF),
    GM("GM", "Gambia", "冈比亚", Continent.AF),
    GE("GE", "Georgia", "格鲁吉亚", Continent.AS),
    GH("GH", "Ghana", "加纳", Continent.AF),
    GI("GI", "Gibraltar", "直布罗陀", Continent.EU),
    GR("GR", "Greece", "希腊", Continent.EU),
    GL("GL", "Greenland", "格陵兰", Continent.NA),
    GD("GD", "Grenada", "格林纳达", Continent.NA),
    GP("GP", "Guadeloupe", "瓜德罗普", Continent.NA),
    GU("GU", "Guam", "关岛", Continent.OC),
    GT("GT", "Guatemala", "危地马拉", Continent.NA),
    GG("GG", "Guernsey", "根西", Continent.EU),
    GN("GN", "Guinea", "几内亚", Continent.AF),
    GW("GW", "Guinea-Bissau", "几内亚比绍", Continent.AF),
    GY("GY", "Guyana", "圭亚那", Continent.SA),

    // H
    HT("HT", "Haiti", "海地", Continent.NA),
    HM("HM", "Heard Island and McDonald Islands", "赫德岛和麦克唐纳群岛", Continent.OC),
    VA("VA", "Holy See", "梵蒂冈", Continent.EU),
    HN("HN", "Honduras", "洪都拉斯", Continent.NA),
    HU("HU", "Hungary", "匈牙利", Continent.EU),

    // I
    IS("IS", "Iceland", "冰岛", Continent.EU),
    ID("ID", "Indonesia", "印度尼西亚", Continent.AS),
    IR("IR", "Iran (Islamic Republic of)", "伊朗", Continent.AS),
    IQ("IQ", "Iraq", "伊拉克", Continent.AS),
    IE("IE", "Ireland", "爱尔兰", Continent.EU),
    IM("IM", "Isle of Man", "马恩岛", Continent.EU),
    IL("IL", "Israel", "以色列", Continent.AS),

    // J
    JM("JM", "Jamaica", "牙买加", Continent.NA),
    JE("JE", "Jersey", "泽西", Continent.EU),
    JO("JO", "Jordan", "约旦", Continent.AS),

    // K
    KZ("KZ", "Kazakhstan", "哈萨克斯坦", Continent.AS),
    KE("KE", "Kenya", "肯尼亚", Continent.AF),
    KI("KI", "Kiribati", "基里巴斯", Continent.OC),
    KP("KP", "Korea (Democratic People's Republic of)", "朝鲜", Continent.AS),
    KW("KW", "Kuwait", "科威特", Continent.AS),
    KG("KG", "Kyrgyzstan", "吉尔吉斯斯坦", Continent.AS),

    // L
    LA("LA", "Lao People's Democratic Republic", "老挝", Continent.AS),
    LV("LV", "Latvia", "拉脱维亚", Continent.EU),
    LB("LB", "Lebanon", "黎巴嫩", Continent.AS),
    LS("LS", "Lesotho", "莱索托", Continent.AF),
    LR("LR", "Liberia", "利比里亚", Continent.AF),
    LY("LY", "Libya", "利比亚", Continent.AF),
    LI("LI", "Liechtenstein", "列支敦士登", Continent.EU),
    LT("LT", "Lithuania", "立陶宛", Continent.EU),
    LU("LU", "Luxembourg", "卢森堡", Continent.EU),

    // M
    MG("MG", "Madagascar", "马达加斯加", Continent.AF),
    MW("MW", "Malawi", "马拉维", Continent.AF),
    MV("MV", "Maldives", "马尔代夫", Continent.AS),
    ML("ML", "Mali", "马里", Continent.AF),
    MT("MT", "Malta", "马耳他", Continent.EU),
    MH("MH", "Marshall Islands", "马绍尔群岛", Continent.OC),
    MQ("MQ", "Martinique", "马提尼克", Continent.NA),
    MR("MR", "Mauritania", "毛里塔尼亚", Continent.AF),
    MU("MU", "Mauritius", "毛里求斯", Continent.AF),
    YT("YT", "Mayotte", "马约特", Continent.AF),
    FM("FM", "Micronesia (Federated States of)", "密克罗尼西亚联邦", Continent.OC),
    MD("MD", "Moldova (Republic of)", "摩尔多瓦", Continent.EU),
    MC("MC", "Monaco", "摩纳哥", Continent.EU),
    MN("MN", "Mongolia", "蒙古", Continent.AS),
    ME("ME", "Montenegro", "黑山", Continent.EU),
    MS("MS", "Montserrat", "蒙特塞拉特", Continent.NA),
    MA("MA", "Morocco", "摩洛哥", Continent.AF),
    MZ("MZ", "Mozambique", "莫桑比克", Continent.AF),
    MM("MM", "Myanmar", "缅甸", Continent.AS),

    // N
    NA("NA", "Namibia", "纳米比亚", Continent.AF),
    NR("NR", "Nauru", "瑙鲁", Continent.OC),
    NP("NP", "Nepal", "尼泊尔", Continent.AS),
    NC("NC", "New Caledonia", "新喀里多尼亚", Continent.OC),
    NI("NI", "Nicaragua", "尼加拉瓜", Continent.NA),
    NE("NE", "Niger", "尼日尔", Continent.AF),
    NG("NG", "Nigeria", "尼日利亚", Continent.AF),
    NU("NU", "Niue", "纽埃", Continent.OC),
    NF("NF", "Norfolk Island", "诺福克岛", Continent.OC),
    MK("MK", "North Macedonia", "北马其顿", Continent.EU),
    MP("MP", "Northern Mariana Islands", "北马里亚纳群岛", Continent.OC),
    NO("NO", "Norway", "挪威", Continent.EU),

    // O
    OM("OM", "Oman", "阿曼", Continent.AS),

    // P
    PK("PK", "Pakistan", "巴基斯坦", Continent.AS),
    PW("PW", "Palau", "帕劳", Continent.OC),
    PS("PS", "Palestine, State of", "巴勒斯坦", Continent.AS),
    PA("PA", "Panama", "巴拿马", Continent.NA),
    PG("PG", "Papua New Guinea", "巴布亚新几内亚", Continent.OC),
    PY("PY", "Paraguay", "巴拉圭", Continent.SA),
    PE("PE", "Peru", "秘鲁", Continent.SA),
    PH("PH", "Philippines", "菲律宾", Continent.AS),
    PN("PN", "Pitcairn", "皮特凯恩群岛", Continent.OC),
    PT("PT", "Portugal", "葡萄牙", Continent.EU),
    PR("PR", "Puerto Rico", "波多黎各", Continent.NA),

    // Q
    QA("QA", "Qatar", "卡塔尔", Continent.AS),
    RE("RE", "Réunion", "留尼汪", Continent.AF),
    RO("RO", "Romania", "罗马尼亚", Continent.EU),
    RW("RW", "Rwanda", "卢旺达", Continent.AF),

    // S
    BL("BL", "Saint Barthélemy", "圣巴泰勒米", Continent.NA),
    SH("SH", "Saint Helena, Ascension and Tristan da Cunha", "圣赫勒拿、阿森松和特里斯坦达库尼亚", Continent.AF),
    KN("KN", "Saint Kitts and Nevis", "圣基茨和尼维斯", Continent.NA),
    LC("LC", "Saint Lucia", "圣卢西亚", Continent.NA),
    MF("MF", "Saint Martin (French part)", "法属圣马丁", Continent.NA),
    PM("PM", "Saint Pierre and Miquelon", "圣皮埃尔和密克隆", Continent.NA),
    VC("VC", "Saint Vincent and the Grenadines", "圣文森特和格林纳丁斯", Continent.NA),
    WS("WS", "Samoa", "萨摩亚", Continent.OC),
    SM("SM", "San Marino", "圣马力诺", Continent.EU),
    ST("ST", "Sao Tome and Principe", "圣多美和普林西比", Continent.AF),
    SA("SA", "Saudi Arabia", "沙特阿拉伯", Continent.AS),
    SN("SN", "Senegal", "塞内加尔", Continent.AF),
    RS("RS", "Serbia", "塞尔维亚", Continent.EU),
    SC("SC", "Seychelles", "塞舌尔", Continent.AF),
    SL("SL", "Sierra Leone", "塞拉利昂", Continent.AF),
    SX("SX", "Sint Maarten (Dutch part)", "荷属圣马丁", Continent.NA),
    SK("SK", "Slovakia", "斯洛伐克", Continent.EU),
    SI("SI", "Slovenia", "斯洛文尼亚", Continent.EU),
    SB("SB", "Solomon Islands", "所罗门群岛", Continent.OC),
    SO("SO", "Somalia", "索马里", Continent.AF),
    GS("GS", "South Georgia and the South Sandwich Islands", "南乔治亚和南桑威奇群岛", Continent.AN),
    SS("SS", "South Sudan", "南苏丹", Continent.AF),
    LK("LK", "Sri Lanka", "斯里兰卡", Continent.AS),
    SD("SD", "Sudan", "苏丹", Continent.AF),
    SR("SR", "Suriname", "苏里南", Continent.SA),
    SJ("SJ", "Svalbard and Jan Mayen", "斯瓦尔巴和扬马延", Continent.EU),
    SY("SY", "Syrian Arab Republic", "叙利亚", Continent.AS),

    // T
    TJ("TJ", "Tajikistan", "塔吉克斯坦", Continent.AS),
    TZ("TZ", "Tanzania, United Republic of", "坦桑尼亚", Continent.AF),
    TL("TL", "Timor-Leste", "东帝汶", Continent.AS),
    TG("TG", "Togo", "多哥", Continent.AF),
    TK("TK", "Tokelau", "托克劳", Continent.OC),
    TO("TO", "Tonga", "汤加", Continent.OC),
    TT("TT", "Trinidad and Tobago", "特立尼达和多巴哥", Continent.NA),
    TN("TN", "Tunisia", "突尼斯", Continent.AF),
    TR("TR", "Turkey", "土耳其", Continent.AS),
    TM("TM", "Turkmenistan", "土库曼斯坦", Continent.AS),
    TC("TC", "Turks and Caicos Islands", "特克斯和凯科斯群岛", Continent.NA),
    TV("TV", "Tuvalu", "图瓦卢", Continent.OC),

    // U
    UG("UG", "Uganda", "乌干达", Continent.AF),
    UA("UA", "Ukraine", "乌克兰", Continent.EU),
    AE("AE", "United Arab Emirates", "阿联酋", Continent.AS),
    UM("UM", "United States Minor Outlying Islands", "美国本土外小岛屿", Continent.OC),
    UY("UY", "Uruguay", "乌拉圭", Continent.SA),
    UZ("UZ", "Uzbekistan", "乌兹别克斯坦", Continent.AS),

    // V
    VU("VU", "Vanuatu", "瓦努阿图", Continent.OC),
    VE("VE", "Venezuela (Bolivarian Republic of)", "委内瑞拉", Continent.SA),
    VG("VG", "Virgin Islands (British)", "英属维尔京群岛", Continent.NA),
    VI("VI", "Virgin Islands (U.S.)", "美属维尔京群岛", Continent.NA),

    // W
    WF("WF", "Wallis and Futuna", "瓦利斯和富图纳", Continent.OC),
    EH("EH", "Western Sahara", "西撒哈拉", Continent.AF),

    // Y
    YE("YE", "Yemen", "也门", Continent.AS),

    // Z
    ZM("ZM", "Zambia", "赞比亚", Continent.AF),
    ZW("ZW", "Zimbabwe", "津巴布韦", Continent.AF)


    ;

    private final String code;
    private final String nameEn;
    private final String nameZh;
    private final Continent continent;

    Country(String code, String nameEn, String nameZh, Continent continent) {
        this.code = code;
        this.nameEn = nameEn;
        this.nameZh = nameZh;
        this.continent = continent;
    }

    public String getCode() {
        return code;
    }

    public String getNameEn() {
        return nameEn;
    }

    public String getNameZh() {
        return nameZh;
    }

    public Continent getContinent() {
        return continent;
    }

    /**
     * 根据国家代码获取国家枚举（忽略大小写）
     */
    public static Country of(String code) {
        if (code == null || code.isEmpty()) {
            return null;
        }
        for (Country country : values()) {
            if (country.code.equalsIgnoreCase(code.trim())) {
                return country;
            }
        }
        return null;
    }
    public static Country ofZhName(String name) {
        if (name == null || name.isEmpty()) {
            return null;
        }
        for (Country country : values()) {
            if (country.nameZh.equalsIgnoreCase(name.trim())) {
                return country;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return code + " - " + nameZh + " (" + nameEn + "), " + continent.getNameZh();
    }
}